package com.example.tx;

import com.example.tx.domain.TxTest;
import com.example.tx.service.TxTestService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * <p> Novel 控制器 </p>
 *
 * @author Chris
 * @since 2022/10/28 18:01
 */
@RestController
@RequestMapping("/tx")
public class TxTestController {
    /**
     * 使用 slf4j 日志框架
     */
    private final static Logger log = LoggerFactory.getLogger(TxTestController.class);

    private final TxTestService txTestService;

    public TxTestController(TxTestService txTestService) {
        this.txTestService = txTestService;
    }

    @PostMapping("/save")
    public TxTest saveNovel(TxTest txTest) {
        log.info("{}", txTest);

        txTest.setTxTime(new Date());

        txTestService.save(txTest);

        return txTest;
    }

}